package com.woniu.product.controller;


import com.woniu.common.utils.ResponseData;
import com.woniu.product.utils.MinioUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class MinioController {
    @Autowired
    private MinioUtils minioUtils;

    /**
     * 怎么接收文件类型：MultipartFile
     * @param file
     * @return
     */
    @PostMapping("/uploadimg")
    public ResponseData<?> uploadimg(MultipartFile file ) {

        try {
            return minioUtils.uploadFile(file, "img");
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}
